#!/bin/bash
#源码安装Nginx.
cd /root/
if [ ! -f lnmp_soft.tar.gz ];then
   echo "在/root目录下没有找到lnmp_soft.tar.gz"
   exit
fi
tar -xf  lnmp_soft.tar.gz
cd lnmp_soft
tar -xf nginx-1.12.2.tar.gz
cd nginx-1.12.2
yum -y install gcc pcre-devel  openssl-devel
./configure --with-http_ssl_module
make && make install

#yum安装mariadb和PHP.
yum -y install php php-fpm php-mysql
yum -y install mariadb mariadb-server mariadb-devel

#修改nginx配置,实现动静分离.
conf="/usr/local/nginx/conf/nginx.conf"
sed -i  '65,71s/#//'  $conf
sed -i  '/SCRIPT_FILENAME/d'  $conf
sed -i  's/fastcgi_params/fastcgi.conf/'  $conf

#启动服务
systemctl  start  mariadb
systemctl  start  php-fpm
systemctl  enable  mariadb
systemctl  enable  php-fpm
systemctl  stop   httpd
/usr/local/nginx/sbin/nginx

echo /usr/local/nginx/sbin/nginx > /etc/rc.local
chmod +x  /etc/rc.local

